home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri K-CD 2002 #1 / K-CD_2002-01.iso / Delphi / INSTALL / program files / Borland / Delphi6 / Source / Rtl / Win / Nb30.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-05-22  |  9.8 KB  |  272 lines

  1. { *********************************************************************** }
  2. {                                                                         }
  3. { Delphi Runtime Library                                                  }
  4. {                                                                         }
  5. { Copyright (c) 1999-2001 Borland Software Corporation                    }
  6. {                                                                         }
  7. { *********************************************************************** }
  8.  
  9. {*******************************************************}
  10. {       NetBIOS 3.0 interface unit                      }
  11. {*******************************************************}
  12.  
  13. unit Nb30;
  14.  
  15. { This unit contains the definitions
  16.   for portable NetBIOS 3.0 support. }
  17.  
  18. interface
  19.  
  20. uses Windows;
  21.  
  22. { Data structure templates }
  23.  
  24. const
  25.   NCBNAMSZ = 16;               // absolute length of a net name
  26.   MAX_LANA = 254;              // lana's in range 0 to MAX_LANA inclusive
  27.  
  28. type
  29.   // Network Control Block
  30.   PNCB = ^TNCB;
  31.  
  32.   TNCBPostProc = procedure(P: PNCB);
  33.  
  34.   TNCB = packed record
  35.     ncb_command: Char;         // command code
  36.     ncb_retcode: Char;         // return code
  37.     ncb_lsn: Char;             // local session number
  38.     ncb_num: Char;             // number of our network name
  39.     ncb_buffer: PChar;         // address of message buffer
  40.     ncb_length: Word;          // size of message buffer
  41.     ncb_callname: array[0..NCBNAMSZ - 1] of char;  // blank-padded name of remote
  42.     ncb_name: array[0..NCBNAMSZ - 1] of char;      // our blank-padded netname
  43.     ncb_rto: Char;             // rcv timeout/retry count
  44.     ncb_sto: Char;             // send timeout/sys timeout
  45.     ncb_post: TNCBPostProc;    // POST routine address
  46.     ncb_lana_num: Char;        // lana (adapter) number
  47.     ncb_cmd_cplt: Char;        // 0xff => commmand pending
  48.     ncb_reserve: array[0..9] of Char;              // reserved, used by BIOS
  49.     ncb_event: THandle;        // HANDLE to Win32 event which
  50.                                // will be set to the signalled
  51.                                // state when an ASYNCH command
  52.                                // completes
  53.   end;
  54.  
  55.   // Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed
  56.   // by an array of NAME_BUFFER structures.
  57.   PAdapterStatus = ^TAdapterStatus;
  58.   TAdapterStatus = packed record
  59.     adapter_address: array[0..5] of Char;
  60.     rev_major: Char;
  61.     reserved0: Char;
  62.     adapter_type: Char;
  63.     rev_minor: Char;
  64.     duration: Word;
  65.     frmr_recv: Word;
  66.     frmr_xmit: Word;
  67.     iframe_recv_err: Word;
  68.     xmit_aborts: Word;
  69.     xmit_success: DWORD;
  70.     recv_success: DWORD;
  71.     iframe_xmit_err: Word;
  72.     recv_buff_unavail: Word;
  73.     t1_timeouts: Word;
  74.     ti_timeouts: Word;
  75.     reserved1: DWORD;
  76.     free_ncbs: Word;
  77.     max_cfg_ncbs: Word;
  78.     max_ncbs: Word;
  79.     xmit_buf_unavail: Word;
  80.     max_dgram_size: Word;
  81.     pending_sess: Word;
  82.     max_cfg_sess: Word;
  83.     max_sess: Word;
  84.     max_sess_pkt_size: Word;
  85.     name_count: Word;
  86.   end;
  87.  
  88.   PNameBuffer = ^TNameBuffer;
  89.   TNameBuffer = packed record
  90.     name: array[0..NCBNAMSZ - 1] of Char;
  91.     name_num: Char;
  92.     name_flags: Char;
  93.   end;
  94.  
  95. const
  96.   // values for name_flags bits.
  97.   NAME_FLAGS_MASK = $87;
  98.  
  99.   GROUP_NAME      = $80;
  100.   UNIQUE_NAME     = $00;
  101.  
  102.   REGISTERING     = $00;
  103.   REGISTERED      = $04;
  104.   DEREGISTERED    = $05;
  105.   DUPLICATE       = $06;
  106.   DUPLICATE_DEREG = $07;
  107.  
  108. type
  109.   // Structure returned to the NCB command NCBSSTAT is SESSION_HEADER followed
  110.   // by an array of SESSION_BUFFER structures. If the NCB_NAME starts with an
  111.   // asterisk then an array of these structures is returned containing the
  112.   // status for all names.
  113.   PSessionHeader = ^TSessionHeader;
  114.   TSessionHeader = packed record
  115.     sess_name: Char;
  116.     num_sess: Char;
  117.     rcv_dg_outstanding: Char;
  118.     rcv_any_outstanding: Char;
  119.   end;
  120.  
  121.   PSessionBuffer = ^TSessionBuffer;
  122.   TSessionBuffer = packed record
  123.     lsn: Char;
  124.     state: Char;
  125.     local_name: array[0..NCBNAMSZ - 1] of Char;
  126.     remote_name: array[0..NCBNAMSZ - 1] of Char;
  127.     rcvs_outstanding: Char;
  128.     sends_outstanding: Char;
  129.   end;
  130.  
  131. const
  132.   // Values for state
  133.   LISTEN_OUTSTANDING      = $01;
  134.   CALL_PENDING            = $02;
  135.   SESSION_ESTABLISHED     = $03;
  136.   HANGUP_PENDING          = $04;
  137.   HANGUP_COMPLETE         = $05;
  138.   SESSION_ABORTED         = $06;
  139.  
  140. type
  141.   // Structure returned to the NCB command NCBENUM.
  142.   // On a system containing lana's 0, 2 and 3, a structure with
  143.   // length =3, lana[0]=0, lana[1]=2 and lana[2]=3 will be returned.
  144.   PLanaEnum = ^TLanaEnum;
  145.   TLanaEnum = packed record
  146.     length: Char;         //  Number of valid entries in lana[]
  147.     lana: array[0..MAX_LANA] of Char;
  148.   end;
  149.  
  150.   // Structure returned to the NCB command NCBFINDNAME is FIND_NAME_HEADER followed
  151.   // by an array of FIND_NAME_BUFFER structures.
  152.   PFindNameHeader = ^TFindNameHeader;
  153.   TFindNameHeader = packed record
  154.     node_count: Word;
  155.     reserved: Char;
  156.     unique_group: Char;
  157.   end;
  158.  
  159.   PFindNameBuffer = ^TFindNameBuffer;
  160.   TFindNameBuffer = packed record
  161.     length: Char;
  162.     access_control: Char;
  163.     frame_control: Char;
  164.     destination_addr: array[0..5] of Char;
  165.     source_addr: array[0..5] of Char;
  166.     routing_info: array[0..17] of Char;
  167.   end;
  168.  
  169.   // Structure provided with NCBACTION. The purpose of NCBACTION is to provide
  170.   // transport specific extensions to netbios.
  171.   PActionHeader = ^TActionHeader;
  172.   TActionHeader = packed record
  173.     transport_id: Longint;
  174.     action_code: Word;
  175.     reserved: Word;
  176.   end;
  177.  
  178. const
  179.   // Values for transport_id
  180.   ALL_TRANSPORTS  = 'M'#0#0#0;
  181.   MS_NBF          = 'MNBF';
  182.  
  183.  
  184. { Special values and constants }
  185.  
  186. const
  187.   // NCB Command codes
  188.   NCBCALL         = $10;            // NCB CALL
  189.   NCBLISTEN       = $11;            // NCB LISTEN
  190.   NCBHANGUP       = $12;            // NCB HANG UP
  191.   NCBSEND         = $14;            // NCB SEND
  192.   NCBRECV         = $15;            // NCB RECEIVE
  193.   NCBRECVANY      = $16;            // NCB RECEIVE ANY
  194.   NCBCHAINSEND    = $17;            // NCB CHAIN SEND
  195.   NCBDGSEND       = $20;            // NCB SEND DATAGRAM
  196.   NCBDGRECV       = $21;            // NCB RECEIVE DATAGRAM
  197.   NCBDGSENDBC     = $22;            // NCB SEND BROADCAST DATAGRAM
  198.   NCBDGRECVBC     = $23;            // NCB RECEIVE BROADCAST DATAGRAM
  199.   NCBADDNAME      = $30;            // NCB ADD NAME
  200.   NCBDELNAME      = $31;            // NCB DELETE NAME
  201.   NCBRESET        = $32;            // NCB RESET
  202.   NCBASTAT        = $33;            // NCB ADAPTER STATUS
  203.   NCBSSTAT        = $34;            // NCB SESSION STATUS
  204.   NCBCANCEL       = $35;            // NCB CANCEL
  205.   NCBADDGRNAME    = $36;            // NCB ADD GROUP NAME
  206.   NCBENUM         = $37;            // NCB ENUMERATE LANA NUMBERS
  207.   NCBUNLINK       = $70;            // NCB UNLINK
  208.   NCBSENDNA       = $71;            // NCB SEND NO ACK
  209.   NCBCHAINSENDNA  = $72;            // NCB CHAIN SEND NO ACK
  210.   NCBLANSTALERT   = $73;            // NCB LAN STATUS ALERT
  211.   NCBACTION       = $77;            // NCB ACTION
  212.   NCBFINDNAME     = $78;            // NCB FIND NAME
  213.   NCBTRACE        = $79;            // NCB TRACE
  214.  
  215.   ASYNCH          = $80;            // high bit set = asynchronous
  216.  
  217.   // NCB Return codes
  218.   NRC_GOODRET     = $00;    // good return
  219.                             // also returned when ASYNCH request accepted
  220.   NRC_BUFLEN      = $01;    // illegal buffer length
  221.   NRC_ILLCMD      = $03;    // illegal command
  222.   NRC_CMDTMO      = $05;    // command timed out
  223.   NRC_INCOMP      = $06;    // message incomplete, issue another command
  224.   NRC_BADDR       = $07;    // illegal buffer address
  225.   NRC_SNUMOUT     = $08;    // session number out of range
  226.   NRC_NORES       = $09;    // no resource available
  227.   NRC_SCLOSED     = $0a;    // session closed
  228.   NRC_CMDCAN      = $0b;    // command cancelled
  229.   NRC_DUPNAME     = $0d;    // duplicate name
  230.   NRC_NAMTFUL     = $0e;    // name table full
  231.   NRC_ACTSES      = $0f;    // no deletions, name has active sessions
  232.   NRC_LOCTFUL     = $11;    // local session table full
  233.   NRC_REMTFUL     = $12;    // remote session table full
  234.   NRC_ILLNN       = $13;    // illegal name number
  235.   NRC_NOCALL      = $14;    // no callname
  236.   NRC_NOWILD      = $15;    // cannot put * in NCB_NAME
  237.   NRC_INUSE       = $16;    // name in use on remote adapter
  238.   NRC_NAMERR      = $17;    // name deleted
  239.   NRC_SABORT      = $18;    // session ended abnormally
  240.   NRC_NAMCONF     = $19;    // name conflict detected
  241.   NRC_IFBUSY      = $21;    // interface busy, IRET before retrying
  242.   NRC_TOOMANY     = $22;    // too many commands outstanding, retry later
  243.   NRC_BRIDGE      = $23;    // NCB_lana_num field invalid
  244.   NRC_CANOCCR     = $24;    // command completed while cancel occurring
  245.   NRC_CANCEL      = $26;    // command not valid to cancel
  246.   NRC_DUPENV      = $30;    // name defined by anther local process
  247.   NRC_ENVNOTDEF   = $34;    // environment undefined. RESET required
  248.   NRC_OSRESNOTAV  = $35;    // required OS resources exhausted
  249.   NRC_MAXAPPS     = $36;    // max number of applications exceeded
  250.   NRC_NOSAPS      = $37;    // no saps available for netbios
  251.   NRC_NORESOURCES = $38;    // requested resources are not available
  252.   NRC_INVADDRESS  = $39;    // invalid ncb address or length > segment
  253.   NRC_INVDDID     = $3B;    // invalid NCB DDID
  254.   NRC_LOCKFAIL    = $3C;    // lock of user area failed
  255.   NRC_OPENERR     = $3f;    // NETBIOS not loaded
  256.   NRC_SYSTEM      = $40;    // system error
  257.  
  258.   NRC_PENDING     = $ff;    // asynchronous command is not yet finished
  259.  
  260. { main user entry point for NetBIOS 3.0
  261.    Usage: Result = Netbios( pncb ); }
  262.  
  263.  
  264. function Netbios(P: PNCB): Char; stdcall;
  265.  
  266. implementation
  267.  
  268. function Netbios; external 'netapi32.dll' name 'Netbios';
  269.  
  270. end.
  271.  
  272.